# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
    File Name:  baidu_search
    Author   :  wanwei1029
    Date     :  2018/9/19
    Desc     :
------------------------------------------------------------------------------
"""
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
import time

exepath = r"D:\programFiles\ChromePortable\chromedriver.exe"
chrome_option = Options()
chrome_option.add_argument("--headless")
chrome_option.add_argument('--disable-gpu')
driver = webdriver.Chrome(executable_path=exepath,chrome_options=chrome_option)
driver.get("http://www.baidu.com")
assert u"百度" in driver.title
# driver.refresh()
elem = driver.find_element_by_name("wd")
elem.clear()
elem.send_keys(u"网络爬虫")
elem.send_keys(Keys.RETURN)
time.sleep(3)
# print(driver.page_source)
# assert u"网络爬虫" not in driver.page_source
element=driver.find_element_by_partial_link_text("网络")
print(element.text)
# element.click()

# 鼠标事件
element = driver.find_element_by_link_text("设置")
ActionChains(driver).move_to_element(element).perform()
# driver.close()


def samp():
    """
    """


if __name__ == '__main__':
    test_method = "samp"
    if test_method == "samp":
        samp()